﻿using System;

namespace AgFractal.Fractals
{
    public class PhoenixJulia : AbstractFractal
    {
        public PhoenixJulia()
        {
            Name = Description = "Phoenix julia";
            ID = new Guid("847F6DB1-C69B-401c-B008-E92C6218F0D9");
            R1 = -2.25; I1 = 1.5; R2 = 2.25; I2 = -1.5;
            var cParam = new FractalParameter { Name = "c", ComplexValue = c };
            cParam.PropertyChanged += (s, e) => c = cParam.ComplexValue;
            parameter.Add(cParam);

        }
        private Complex c = new Complex(0.56667, 0);
        protected override short Calculate(double r, double i, short MaxIteration)
        {
            short j;
            Complex z = new Complex(r, i);
            Complex y = new Complex();
            Complex t;
            for (j = 0; j < MaxIteration; j++)
            {
                t = z * z + c - 0.5 * y;
                y = z;
                z = t;
                if (z.Abs2() >= 1e20) break;
            }
            return j;
        }
    }
}